package ai.people.netmon.framework.domain.archives.entity;

import ai.people.netmon.framework.domain.archives.vo.GangGroupOrgPersonListVO;
import ai.people.netmon.utils.StringPool;
import com.alibaba.fastjson.JSONArray;
import lombok.Data;
import lombok.NoArgsConstructor;
import org.apache.commons.lang3.StringUtils;

import java.util.Collections;
import java.util.Date;
import java.util.List;

/**
 * @author zhenglin
 * @date 2022/6/21
 */
@Data
@NoArgsConstructor
public class GangGroupOrgPersonListBO {
    private Long id;
    /**
     * 图片
     */
    private String picture;
    /**
     * 姓名
     */
    private String name;
    /**
     * 身份证
     *
     */
    private String idNumber;

    /**
     * 电话号码
     */
    private String phoneNumber;
    /**
     * 创建者账号
     */
    private String creatorName;
    /**
     * 个人信息
     */
    private String personalSituation;

    /**
     * 档案研判
     */
    private String archivesJudgment;
    /**
     * 团伙身份
     */
    private String groupIdentity;
    /**
     * 危险程度
     */
    private Integer degreeOfDanger;
    /**
     * 标签
     */
    private String tags;
    /**
     * 社交信息
     */
    private String socials;

    /**
     * 更新时间
     */
    private Date updateTime;

    public String buildNameFirst() {
        if (StringUtils.isNotBlank(name)) {
            String[] split = name.split(StringPool.COMMA);
            if (split.length > 0) {
                return split[0];
            }
        }
        return null;
    }

    public String buildInfo() {
        if (StringUtils.isNotBlank(archivesJudgment)){
            return archivesJudgment;
        }
        if (StringUtils.isNotBlank(personalSituation)){
            return personalSituation;
        }
        return null;
    }

    public List<String> buildTagsList() {
        if (StringUtils.isNotBlank(tags)) {
            return List.of(StringUtils.split(tags, StringPool.COMMA));
        }
        return Collections.emptyList();
    }

    public List<GangGroupOrgPersonListVO.Social> buildSocials() {
        if (StringUtils.isNotBlank(socials)) {
            return JSONArray.parseArray(socials, GangGroupOrgPersonListVO.Social.class);
        }
        return Collections.emptyList();
    }

    public List<String> buildPhoneNumberList() {
        if (StringUtils.isNotBlank(phoneNumber)) {
            return List.of(StringUtils.split(phoneNumber, StringPool.COMMA));
        }
        return Collections.emptyList();
    }
}
